package unit4;

public class Ex4_10_TestShape {
    public static void main(String[] args) {
        drawShape(new Circle1());
        drawShape(new Square1());
        drawShape(new Triangle1());
    }
    static void drawShape(Shape1 s) { //s 可以是实现Shape接口的任何类的对象
        s.draw();
    }
}

interface Shape1 { //定义接口
    void draw();
}
class Circle1 implements Shape1 {
    public void draw() {
        System.out.println("draw Circle.");
    }
}
class Square1 implements Shape1 {
    public void draw() {
        System.out.println("draw Square.");
    }
}
class Triangle1 implements Shape1 {
    public void draw() {
        System.out.println("draw riangle.");
    }
}
